1 /***
2 *
3 */
4 package ar.com.epere4.util.lang;
5
6 import java.lang.reflect.Array;
7
8 /***
9 * This class implements some utility methods to manipulate arrays and that are
10 * not present in classes such as {@link org.apache.commons.lang.ArrayUtils}.
11 *
12 * @author epere4
13 * @since 22/02/2006
14 */
15 public final class ArrayUtils {
16
17 /***
18 * No instances.
19 *
20 * @since 22/02/2006
21 */
22 private ArrayUtils() {
23
24 }
25
26 /***
27 * Concatenates the two arrays of type arrayType. The returned value can be
28 * casted to arrayType[].
29 *
30 * @param arr1
31 * the first array to concat.
32 * @param arr2
33 * the second array to concat.
34 * @param arrayType
35 * the type of the arrays.
36 * @return a new array with both arrays concatenated.
37 * @since 22/02/2006
38 */
39 public static Object concatArrays(final Object[] arr1, final Object[] arr2,
40 final Class arrayType) {
41 Object destination = Array.newInstance(arrayType, arr1.length
42 + arr2.length);
43
44 System.arraycopy(arr1, 0, destination, 0, arr1.length);
45 System.arraycopy(arr2, 0, destination, arr1.length, arr2.length);
46
47 return destination;
48 }
49
50 }